<?php
class UserModel extends Model
{//用户管理模块
    // 自动验证设置 
    protected $_validate = array( 
        array('account','require','登陆账号必须！',1),
        //array('nickname','require','标题必须！',1),
        array('passwd','require','密码必须！',1,'','add'),
        array('verify','number','verify输入错误！',1),
        array('email','email','邮箱格式错误！',2),
        //array('remark','require','说明内容必须',1),
        array('status','number','verify输入错误！',1),
        array('account','','登陆账号已经存在',0,'unique','add'),
        );

    protected $_auto = array(
        array('create_time','time','ADD','function'),
        array('update_time','time','ADD','function'),
        array('update_time','time','UPDATE','function'),
        array('passwd','md5','ADD','function'),
        array('passwd','make_usermd5pw','UPDATE','callback'),
	);
	
	public function CheckVerify() {
		return md5($_POST['passwd']);
	}
	
	public function make_usermd5pw() 
	{//返回用户md5的密码
		if (empty($_POST['passwd'])){
			unset($_POST['passwd']);
		}else{
			return md5(trim($_POST['passwd']));
		}
		//这句会出错 return isset($_POST['passwd'])? md5(trim($_POST['passwd'])) : unset($_POST['passwd']);
	}
	
	
	
	/*
	protected $viewModel = true;
	 
	// 视图模型中的字段定义 
	protected $viewFields = array( 
		"User"=>array("gid","field2","field3"), 
		"Model2"=>array("field1","field2") 
	); 

	// 视图关联的where条件 
	protected $viewCondition = array("Model1.field1" => array("eqf","Model2.field1")); 
	 
	// 视图模型的主键
	Public function getPk() { 
		return "Model1.field1"; 
	}



	var $_validate = array( 
		//array("title","require","标题不能为空",1) 
	); 

	var $_link = array( 
	array( "mapping_type"=>HAS_ONE, 
			"class_name"=>"", 
			"foreign_key"=>"", 
			"mapping_name"=>"", 
		 ) 
	);
	*/
} 
?>